package cn.fufeiii.bt.nomiddleware.openfeign;

import cn.fufeiii.bt.common.aspect.response.ResponseWrapper;
import cn.fufeiii.bt.nomiddleware.openfeign.api.StudentApi;
import cn.fufeiii.bt.nomiddleware.openfeign.dto.AddRequest;
import cn.fufeiii.bt.nomiddleware.openfeign.dto.GetListRequest;
import cn.fufeiii.bt.nomiddleware.openfeign.dto.GetListResponse;
import cn.fufeiii.bt.nomiddleware.openfeign.dto.GetResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 当前程序的测试feignclient触发器
 *
 * @author FuFei
 */
@ResponseWrapper
@RestController
@RequestMapping("/rest/test")
public class MainTestController implements StudentApi {
    @Autowired
    private StudentApiFeignClient studentApiFeignClient;

    @ResponseWrapper
    @PostMapping(PATH_ADD)
    @Override
    public void add(@RequestBody AddRequest addRequest) {
        studentApiFeignClient.add(addRequest);
    }

    @ResponseWrapper
    @GetMapping(PATH_GET)
    @Override
    public GetResponse get(@PathVariable Long id) {
        return studentApiFeignClient.get(id);
    }


    @ResponseWrapper
    @PostMapping(PATH_GET_LIST)
    @Override
    public List<GetListResponse> getList(@RequestBody GetListRequest request) {
        return studentApiFeignClient.getList(request);
    }

}
